const mongoose = require('mongoose');

const { Schema, model } = mongoose;
const commentSchema = new Schema({
  __v: { type: Number, select: false },
  content: { type: String, required: true },//评论内容
  commentator: { type: Schema.Types.ObjectId, ref: 'User', required: true, select: false },//评论人
  questionId: { type: String, required: true },//属于哪个问题
  answerId: { type: String, required: true },//回答id
  rootCommentId: { type: String },//根评论id
  replyTo: { type: Schema.Types.ObjectId, ref: 'User' },//回复哪个用户
}, { timestamps: true });

module.exports = model('Comment', commentSchema);